Imports System.Data
Imports System.Data.SqlClient
Namespace TVN
    Public Class WORKPRINTING
        ' Dim drRev As New ERP.DRREVIEW
        Dim cn As New ERP.CONNECTION
        
        Public Function getShortData(ByVal Pro As String) As SqlDataReader
            'Dim strConect As String = HRConnectionClass.GetConnectionString("ConnectionString")
            'Dim cn As New SqlConnection(strConect)
            Dim dr As SqlDataReader = Nothing
            Try

                Dim cmd As New SqlCommand(Pro, cn.OpenConnectionSQL("woprinting"))
                cmd.CommandType = CommandType.StoredProcedure

                'cn.Open()
                dr = cmd.ExecuteReader(CommandBehavior.CloseConnection)

            Catch ex As Exception
                MsgBox(ex.ToString)
            End Try
            Return dr

        End Function
        Public Sub EmptyOldData()
            Dim cmd As New SqlCommand("EmptyOldData", cn.OpenConnectionSQL("woprinting"))
            cmd.CommandType = CommandType.StoredProcedure
            'cn.Open()
            cmd.ExecuteNonQuery()
            'cn.Close()
        End Sub
        Public Sub InsertNewdData()

            'Dim strConect As String = HRConnectionClass.GetConnectionString("ConnectionString")
            'Dim cn As New SqlConnection(strConect)
            Dim cmd As New SqlCommand("GetDataFromACCPAC", cn.OpenConnectionSQL("woprinting"))
            cmd.CommandType = CommandType.StoredProcedure
            ' cn.Open()
            cmd.ExecuteNonQuery()
            'cn.Close()
        End Sub
        Public Sub CheckWoExitsOrNot(ByVal wo As Integer)
            'Dim strConect As String = HRConnectionClass.G
            'Dim cn As New SqlConnection(strConect)

            Dim cmd As New SqlCommand("WOPrinting_CheckWoExits", cn.OpenConnectionSQL("woprinting"))
            cmd.CommandType = CommandType.StoredProcedure
            cmd.Parameters.Add(New SqlParameter("@Wo", SqlDbType.Int))
            cmd.Parameters("@Wo").Value = wo
            'cn.Open()
            cmd.ExecuteNonQuery()
            'cn.Close()
        End Sub
        Public Function Get_AR_HDR(ByVal cust As String, ByVal WbNull As Integer) As SqlDataReader
            'Dim strConect As String = HRConnectionClass.GetConnectionString("ConnectionString")
            'Dim cn As New SqlConnection(strConect)
            Dim cmd As New SqlCommand("Get_AR_HDR", cn.OpenConnectionSQL("woprinting"))
            cmd.Parameters.Add(New SqlParameter("@cust", SqlDbType.VarChar, 10))
            cmd.Parameters.Add(New SqlParameter("@AWBNull", SqlDbType.TinyInt))
            cmd.Parameters("@cust").Value = cust
            cmd.Parameters("@AWBNull").Value = WbNull
            cmd.CommandType = CommandType.StoredProcedure
            Dim dr As SqlDataReader
            'cn.Open()
            dr = cmd.ExecuteReader(CommandBehavior.CloseConnection)
            Return dr
        End Function
        Public Sub Update_AR_HDR(ByVal inv As Integer, ByVal Wb As String, ByVal custNo As String)
            'Dim strConect As String = HRConnectionClass.GetConnectionString("ConnectionString")
            'Dim cn As New SqlConnection(strConect)
            Dim cmd As New SqlCommand("Update_AR_HDR", cn.OpenConnectionSQL("woprinting"))
            cmd.CommandType = CommandType.StoredProcedure
            cmd.Parameters.Add(New SqlParameter("@INV", SqlDbType.Int))
            cmd.Parameters.Add(New SqlParameter("@WB", SqlDbType.VarChar, 30))
            cmd.Parameters.Add(New SqlParameter("@CustomNo", SqlDbType.VarChar, 30))
            cmd.Parameters("@INV").Value = inv
            cmd.Parameters("@WB").Value = Wb
            cmd.Parameters("@CustomNo").Value = custNo
            ' cn.Open()
            cmd.ExecuteNonQuery()
            'cn.Close()
        End Sub
        Public Sub Update_SO_HDR(ByVal CUSTPO As String, ByVal SHIPVIA As String, ByVal TERM As String, ByVal So As Integer)
            'Dim strConect As String = HRConnectionClass.GetConnectionString("ConnectionString")
            'Dim cn As New SqlConnection(strConect)

            Dim cmd As New SqlCommand("Update_SO_HDR", cn.OpenConnectionSQL("woprinting"))
            cmd.CommandType = CommandType.StoredProcedure
            cmd.Parameters.Add(New SqlParameter("@CUSTPO", SqlDbType.VarChar, 30))
            cmd.Parameters.Add(New SqlParameter("@SHIPVIA", SqlDbType.VarChar, 30))
            cmd.Parameters.Add(New SqlParameter("@TERM", SqlDbType.VarChar, 30))
            cmd.Parameters.Add(New SqlParameter("@So", SqlDbType.Int))
            cmd.Parameters("@CUSTPO").Value = CUSTPO
            cmd.Parameters("@SHIPVIA").Value = SHIPVIA
            cmd.Parameters("@TERM").Value = TERM
            cmd.Parameters("@So").Value = So
            ' cn.Open()
            cmd.ExecuteNonQuery()
            'cn.Close()
        End Sub

        Public Sub Update_SO_dtl(ByVal remain As Integer, ByVal qtyshp As Integer, ByVal qty As Double, ByVal WO As Double, ByVal pickupdate As String, ByVal inhousedate As String, ByVal price As Double, ByVal sodtl As String)
            'Dim strConect As String = HRConnectionClass.GetConnectionString("ConnectionString")
            'Dim cn As New SqlConnection(strConect)

            Dim cmd As New SqlCommand("Update_SO_dtl", cn.OpenConnectionSQL("woprinting"))
            cmd.CommandType = CommandType.StoredProcedure
            cmd.Parameters.Add(New SqlParameter("@remain", SqlDbType.Int))
            cmd.Parameters.Add(New SqlParameter("@qtyshp", SqlDbType.Int))
            cmd.Parameters.Add(New SqlParameter("@qty", SqlDbType.Float))
            cmd.Parameters.Add(New SqlParameter("@WO", SqlDbType.Float))
            cmd.Parameters.Add(New SqlParameter("@pickupdate", SqlDbType.DateTime))
            cmd.Parameters.Add(New SqlParameter("@inhousedate", SqlDbType.DateTime))
            cmd.Parameters.Add(New SqlParameter("@price", SqlDbType.Float))
            cmd.Parameters.Add(New SqlParameter("@sodtl", SqlDbType.VarChar, 10))
            cmd.Parameters("@remain").Value = remain
            cmd.Parameters("@qtyshp").Value = qtyshp
            cmd.Parameters("@qty").Value = qty
            cmd.Parameters("@WO").Value = WO
            cmd.Parameters("@pickupdate").Value = pickupdate
            cmd.Parameters("@inhousedate").Value = inhousedate
            cmd.Parameters("@price").Value = price
            cmd.Parameters("@sodtl").Value = sodtl
            'cn.Open()
            cmd.ExecuteNonQuery()
            ' cn.Close()
        End Sub
        Public Sub Update_AR_HDRInReport(ByVal inv As Integer, ByVal shipVia As String, ByVal dates As String)
            'Dim strConect As String = HRConnectionClass.GetConnectionString("ConnectionString")
            'Dim cn As New SqlConnection(strConect)

            Dim cmd As New SqlCommand("Update_AR_HDRInReport", cn.OpenConnectionSQL("woprinting"))
            cmd.CommandType = CommandType.StoredProcedure
            cmd.Parameters.Add(New SqlParameter("@ShipVia", SqlDbType.VarChar, 50))
            cmd.Parameters.Add(New SqlParameter("@Date", SqlDbType.DateTime))
            cmd.Parameters.Add(New SqlParameter("@Inv", SqlDbType.Int))
            cmd.Parameters("@ShipVia").Value = shipVia
            cmd.Parameters("@Date").Value = dates
            cmd.Parameters("@Inv").Value = inv
        End Sub
        Public Function ReturnSQLDataReader(ByVal SqlString As String) As SqlDataReader
            'Dim strConect As String = HRConnectionClass.GetConnectionString("ConnectionString")
            'Dim cn As New SqlConnection(strConect)

            Dim cmd As New SqlCommand(SqlString, cn.OpenConnectionSQL("woprinting"))
            cmd.CommandType = CommandType.StoredProcedure
            Dim dr As SqlDataReader
            'cn.Open()
            dr = cmd.ExecuteReader(CommandBehavior.CloseConnection)
            Return dr
        End Function
        Public Sub ExcecuteNoneQuery(ByVal SqlString As String)
            'Dim strConect As String = HRConnectionClass.GetConnectionString("ConnectionString")
            'Dim cn As New SqlConnection(strConect)

            Dim cmd As New SqlCommand(SqlString, cn.OpenConnectionSQL("woprinting"))
            cmd.CommandType = CommandType.StoredProcedure
            cmd.CommandText = SqlString
            'cn.Open()
            cmd.ExecuteNonQuery()
            ' cn.Close()
            cmd = Nothing
        End Sub
    End Class

End Namespace


